package com.zhengb.flink.study.datastream.sourcefunction;

import com.zhengb.flink.study.datastream.datasource.RandomParallelSource;
import lombok.extern.slf4j.Slf4j;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.sink.SinkFunction;

/**
 * 自定义 richParallel source
 *
 * @author zhengbo
 * @date 2019/12/19
 */
@Slf4j
public class CustomRichParallelSourceFunction {

    public static void main(String[] args) throws Exception {

        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.addSource(new RandomParallelSource()).setParallelism(10).addSink(new SinkFunction<Long>() {
            @Override
            public void invoke(Long value, Context context) throws Exception {
                log.info("sink data:{}", value);
            }
        }).setParallelism(5);

        env.execute("CustomRichParallelSourceFunction");
    }


}
